package com.yinhe.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yinhe.common.annotation.Log;
import com.yinhe.common.core.controller.BaseController;
import com.yinhe.common.core.domain.AjaxResult;
import com.yinhe.common.enums.BusinessType;
import com.yinhe.system.domain.YhFormsign;
import com.yinhe.system.service.IYhFormsignService;
import com.yinhe.common.utils.poi.ExcelUtil;
import com.yinhe.common.core.page.TableDataInfo;

/**
 * 人员签到Controller
 * 
 * @author yinhe
 * @date 2022-10-12
 */
@RestController
@RequestMapping("/system/formsign")
public class YhFormsignController extends BaseController
{
    @Autowired
    private IYhFormsignService yhFormsignService;

    /**
     * 查询人员签到列表
     */
    @PreAuthorize("@ss.hasPermi('system:formsign:list')")
    @GetMapping("/list")
    public TableDataInfo list(YhFormsign yhFormsign)
    {
        startPage();
        List<YhFormsign> list = yhFormsignService.selectYhFormsignList(yhFormsign);
        return getDataTable(list);
    }

    /**
     * 导出人员签到列表
     */
    @PreAuthorize("@ss.hasPermi('system:formsign:export')")
    @Log(title = "人员签到", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YhFormsign yhFormsign)
    {
        List<YhFormsign> list = yhFormsignService.selectYhFormsignList(yhFormsign);
        ExcelUtil<YhFormsign> util = new ExcelUtil<YhFormsign>(YhFormsign.class);
        util.exportExcel(response, list, "人员签到数据");
    }

    /**
     * 获取人员签到详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:formsign:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(yhFormsignService.selectYhFormsignById(id));
    }

    /**
     * 新增人员签到
     */
    @PreAuthorize("@ss.hasPermi('system:formsign:add')")
    @Log(title = "人员签到", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YhFormsign yhFormsign)
    {
        return toAjax(yhFormsignService.insertYhFormsign(yhFormsign));
    }

    /**
     * 修改人员签到
     */
    @PreAuthorize("@ss.hasPermi('system:formsign:edit')")
    @Log(title = "人员签到", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YhFormsign yhFormsign)
    {
        return toAjax(yhFormsignService.updateYhFormsign(yhFormsign));
    }

    /**
     * 删除人员签到
     */
    @PreAuthorize("@ss.hasPermi('system:formsign:remove')")
    @Log(title = "人员签到", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yhFormsignService.deleteYhFormsignByIds(ids));
    }
}
